<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>评价页面</title>
</head>
<body>
	<%@include file="/WEB-INF/jsp/top.jsp" %>
	<h6><a href="${pageContext.request.contextPath }/index2">回到主页</a></h6>
	<h6><a href="${pageContext.request.contextPath }/orders/orderss">回到订单页</a></h6>
	星级1-5：<input type="number" id="s" name="star" placeholder="请输入星级"
		onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-5]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" 
		onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-5]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
	</br>评价内容：<textarea id="c" name="content" cols="40" rows="4" style="OVERFLOW:hidden" placeholder="请输入评价"></textarea></br>
	<button type="button" onclick="addPinglun()">提交评论</button>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/jquery-3.5.1.js"></script>
<script type="text/javascript">
	function addPinglun(){
		if($("#s").val()==""){
			$("#s").val("3");
		}
		var jsonObj={"sid":${sid},"star":$("#s").val(),"content":$("#c").val(),"oid":${oid}};
		$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath }/pingjia/insertPingjia",
			data:jsonObj,
			success:function(result){
				if(result==1){
					alert("评价成功！");
					window.location.href="${pageContext.request.contextPath}/store/store?id=${sid}";
				}
			}
		});
	}
</script>
</html>